package com.example.yichuangyun.mvvm.ui.activity.view;

import androidx.lifecycle.MutableLiveData;

import com.example.yichuangyun.config.Constant;
import com.example.yichuangyun.model.company.IntellectualPropertyDataModel;
import com.example.yichuangyun.model.company.ManageInfoDataModel;
import com.example.yichuangyun.model.company.RiskInfoDataModel;
import com.example.yichuangyun.mvvm.base.BaseViewModel;
import com.example.yichuangyun.mvvm.di.retrofit.BaseModel;
import com.example.yichuangyun.mvvm.di.retrofit.BaseNetCallback;

public class RiskInfoViewModel extends BaseViewModel {

    public MutableLiveData<RiskInfoDataModel> riskInfoDataModelMutableLiveData = new MutableLiveData<>();
    public MutableLiveData<ManageInfoDataModel> manageInfoDataModelMutableLiveData = new MutableLiveData<>();
    public MutableLiveData<IntellectualPropertyDataModel> intellectualPropertyDataModelMutableLiveData = new MutableLiveData<>();

    /**
     * 风险信息
     */
    public void getRiskInfo(String eid) {
        addSubscribe(mRetrofitHelper.getRiskInfo(eid).subscribeWith(new BaseNetCallback<RiskInfoDataModel>() {

            @Override
            public void onSuccess(BaseModel<RiskInfoDataModel> baseModel) {
                if (Constant.SUCCESS == baseModel.getCode()) {
                    if (null != baseModel.getData()) {
                        riskInfoDataModelMutableLiveData.setValue(baseModel.getData());
                    }
                }
            }
        }));
    }

    /**
     * 经营信息
     */
    public void getManageInfo(String eid) {
        addSubscribe(mRetrofitHelper.getManageInfo(eid).subscribeWith(new BaseNetCallback<ManageInfoDataModel>() {

            @Override
            public void onSuccess(BaseModel<ManageInfoDataModel> baseModel) {
                if (Constant.SUCCESS == baseModel.getCode()) {
                    if (null != baseModel.getData()) {
                        manageInfoDataModelMutableLiveData.setValue(baseModel.getData());
                    }
                }
            }
        }));
    }

    /**
     * 知识产权
     */
    public void getIntellectualProperty(String eid) {
        addSubscribe(mRetrofitHelper.getIntellectualProperty(eid).subscribeWith(new BaseNetCallback<IntellectualPropertyDataModel>() {

            @Override
            public void onSuccess(BaseModel<IntellectualPropertyDataModel> baseModel) {
                if (Constant.SUCCESS == baseModel.getCode()) {
                    if (null != baseModel.getData()) {
                        intellectualPropertyDataModelMutableLiveData.setValue(baseModel.getData());
                    }
                }
            }
        }));
    }
}
